<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人资料</title>
    <link href="__PUBLIC__/layui/css/layui.css" rel="stylesheet" />
    <link rel="stylesheet" href="__PUBLIC__/css/global.css" media="all">
    <link href="__PUBLIC__/Font-Awesome/css/font-awesome.css" rel="stylesheet" />
</head>
<body>
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">用户姓名：</label>
            <div class="layui-input-inline">
                <input type="text" name="username"  lay-verify="required|username" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{$memberinfo['username']}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱：</label>
            <div class="layui-input-inline">
                <input type="text" name="phone"  lay-verify="required" placeholder="" autocomplete="off" class="layui-input layui-disabled" value="{$memberinfo['eamil']}" disabled="disabled">
            </div>
            <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="邮箱不能修改">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" placeholder="不输入密码则不修改" lay-verify="pass"  class="layui-input">
            </div>
            <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="不输入密码则不修改">
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit id='sub' lay-filter="tosubmit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
    <script type="text/javascript">
        layui.use('form',function () {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form();


            form.verify({
                username: function(value){
                    if(!new RegExp("^[^(and|or|exec|insert|select|union|update|&&|count|*|%)]*$").test(value)){
                        return '用户名不能有特殊字符';
                    }else if(/(^\_)|(\__)|(\_+$)/.test(value)){
                        return '用户名首尾不能出现下划线\'_\'';
                    }
                    return;
                }
                ,pass: [/^$|^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z_]{6,16}$/, '密码字母和数字组合']
            });

            form.on('submit(tosubmit)',function(data){
                var post = data.field;
                var url = "__SELF__";
                $.post(url,post,function (data) {
                    if(data.code == '101'){
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 2000
                        }, function(){
                            location.reload();
                        });

                    }else{
                        layer.msg(data.msg,{icon: 5});
                        return;
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>